#!/usr/bin/env python
import rospy
import roslib
import rosnode
import sys,os


class node_state():

    def __init__(self):
        rospy.init_node("node_state") 
        rospy.loginfo("node_state program")     
        self.r = rospy.Rate(10)
    def spin(self):
        while not rospy.is_shutdown():
#            nodes=os.popen("rosnode list").readlines()
#            for node in nodes:
#                rospy.loginfo("node list: %s",node)
#                if '/amcl' in node:
#                    rospy.loginfo("/rosout is active")

            string=rosnode.get_node_names()
            rospy.loginfo("node list: %s",string)
            result='/amcl' in string
            rospy.loginfo("result: %s",result)
            self.r.sleep()
if __name__ == '__main__':
    state=node_state()
    state.spin()
